package com.yjc.hire.controller;

import com.yjc.hire.VO.AdminVO;
import com.yjc.hire.bo.UpdateAdminBO;
import com.yjc.hire.grace.result.GraceJSONResult;
import com.yjc.hire.service.AdminService;
import com.yjc.pojo.Admin;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * </p>
 *
 * @author jcyin
 * @since 2025/7/22
 * </p>
 */

@RestController
@RequestMapping("admin")
public class AdminInfoController {

    @Autowired
    private AdminService adminService;

    @PostMapping("myInfo")
    public GraceJSONResult myInfo(@RequestBody String userId){
        Admin admin = adminService.getById(userId);
        AdminVO vo = new AdminVO();
        BeanUtils.copyProperties(admin,vo);
        return GraceJSONResult.ok(vo);
    }


    @PostMapping("updateMyInfo")
    public GraceJSONResult updateMyInfo(@RequestBody UpdateAdminBO bo){
        adminService.update(bo);
        return GraceJSONResult.ok();
    }

}
